list = [1,2,3,4,5]
print(list)
for i in list:
    print(i,end=" ")


print(list[0])
print(list[-1])
print(list[2:])
print(list[::2])
print(list[:3])
print(list[::-1])

list.append(6)
print(list)
list.insert(0,0)
print(list)
list.extend([7,8])
print(list)


list2 = [11,5,33,22,66,1,9]
list2.sort()
print(list2)
list2.sort(reverse=True)
print(list2)

list2_new = sorted(list2)
print(list2)
print(list2_new)

list.pop()
print(list)
list.pop(2)
print(list)
list.remove(5)
print(list)

list[0]= 1
print(list)


list3 = [i for i in list if i % 2 == 0]
print(list3)


tuple = (1,2,3,4,5)
print(tuple)
for item in tuple:
    print(i,end=" ")
print(tuple)
print(tuple[0])
print(tuple[-1])
print(tuple[1:4])
print(tuple[-2:])
print(tuple[:2])
print(tuple[::2])


set1 = set([1,2,3,4,5,3,7,4,1])
print(set1)
set1.pop()
print(set1)
set1.remove(5)
print(set1)



#字典
dict0 = {}
dict1 = dict()
dict2 = {'name':'zhangsan','age':18,'sex':'男'}
print(dict2)
print(dict2['name'])
print(dict2['age'])
for key,value in dict2.items():
    print(key, value)

for key in dict2.keys():
    print(key)

print(dict2.get('id','没有相关数据'))
print(dict2.get('id2'))#返回None

#添加
dict2['id'] = 100#上面不存在id，添加id
print(dict2)
dict2['id'] = 101#上面存在id，就修改id
print(dict2)

dict2.update({'id':'102','sex':'女'})
print(dict2)
dict2.update({'phone':'12345678901','email':'<EMAIL>'})
print(dict2)

#删除
dict2.pop('id')
print(dict2)
item = dict2.popitem()
print(type(item))
print(dict2)
dict2.clear()
print(dict2)